<?php

/**
 * This model contains methods to create code that is used
 * on the user's profile page
 * @author Dominik Imsirovic
 */
class Model_Profile
{

    /**
     *Function to display a list of messages
     * @param type $arr - The array of messages that should be displayed
     * @param type $showTopic - boolean to decide if the the current topic name 
     * should be displayed on the message
     * @author Dominik Imsirovic
     */
    public function showMessages($arr,$showTopic){
    
       
if (count($arr) > 0) {
   for ($i=0 ; $i<5 ; $i++) {
      $post = $arr[$i];
      
      $poster = Model_Users::getUser($post["author"]);
    
      if(!$showTopic){
        $topic="";
      }else{
          $page=Model_Users::getUser($post["topic"]);
            $topic= " on page ".$page["userName"];
        }
      
      echo "<div id=\"post\">";
      echo "<img src=\"..\images\upload/".$poster["picture"]."\" alt=\"picture\" width=\"80\" height=\"80\"/>";
      echo "<div id=\"text\">";
      echo "<h6>Posted on ".$post["date"]." by ".$poster["userName"].$topic."</h6>";
      echo $post["text"]."</div>";
      echo "</div>";
   }
}
else {
         echo "<em>This user didn't post any message yet.</em>";
}
  
        
    }
    
    
      
    
   
  
}    
    ?>
